<!DOCTYPE html>
<html lang="en">
    <head>
        <title></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="js/ajax.js"></script>
        <script>
            window.onload=function(){
                var oBtn=document.getElementById('btn');
                var inp=document.getElementById('inp');
                btn.onclick=function(){
                    ajax({
                        url:'/',
                        data:{name:inp.value},
                        type:'post',
                        success:function(str){
                            var json=eval("("+str+")");
                            if(json.ok){
                                console.log(json.msg)
                                location.replace('/chat');
                            }else{
                                alert(json.msg);
                            }
                            
                        },
                        error:function(){
                            alert('通信失败！')
                        }
                    })
                }
            }
        </script>
    </head>
    <body>
        <h3>用户登录</h3>
       <div>
            请输入你的名称:<input type="text" id='inp'><button id='btn'>进入聊天室</button>
       </div>
              
    </body>
</html>
</html>